Skip to content

Enable CMAKE_MSVC_RUNTIME_LIBRARY support via CMP0091 policy#566

Open
RahulRaj272727 wants to merge 1 commit intomachinezone:masterfrom
RahulRaj272727:feature/cmake-cmp0091-policy
Open

Enable CMAKE_MSVC_RUNTIME_LIBRARY support via CMP0091 policy#566
RahulRaj272727 wants to merge 1 commit intomachinezone:masterfrom
RahulRaj272727:feature/cmake-cmp0091-policy

Conversation

@RahulRaj272727
Copy link

Summary

This PR enables users to configure the MSVC runtime library using CMAKE_MSVC_RUNTIME_LIBRARY (e.g., MultiThreaded or MultiThreadedDebug) for static linking scenarios on Windows.

Problem

Without the CMP0091 policy set to NEW, the CMAKE_MSVC_RUNTIME_LIBRARY CMake variable is ignored. This makes it impossible to build with static runtime (/MT, /MTd) via CMake parameters alone.

Solution

Add a conditional policy check that:

  • Enables CMP0091 when available (CMake 3.15+)
  • Maintains backward compatibility with older CMake versions

Example Usage

After this change, users can build with a static runtime:

cmake -B build -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded

This change enables users to configure the MSVC runtime library using
CMAKE_MSVC_RUNTIME_LIBRARY (e.g., MultiThreaded or MultiThreadedDebug)
for static linking scenarios.

Without this policy set to NEW, CMAKE_MSVC_RUNTIME_LIBRARY is ignored,
making it impossible to build with static runtime (/MT, /MTd) via
CMake parameters alone.

The conditional check ensures backward compatibility with CMake
versions prior to 3.15 where CMP0091 doesn't exist.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant